package org.common.utils.thread;

import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 默认执行器
 * @author zhouzhibing
 * @date 2025/6/11
 */
public class ThreadExecutor implements Executor {

    /**
     * 执行器名称
     */
    private String name;

    /**
     * 线程池
     */
    private final ThreadPoolExecutor threadPoolExecutor;

    /**
     * 构造函数
     * @param name 执行器名称
     */
    public ThreadExecutor(String name) {
        this.name = name;
        this.threadPoolExecutor = ThreadTool.newThreadPoolExecutor(name);
    }

    @Override
    public void execute(Runnable command) {
        threadPoolExecutor.execute(command);
    }
}
